package src.Aula07.Ex02;

public class ObjetoMovel {

    // Coordenadas
    private double x, y;

    public ObjetoMovel(double x, double y) {
        this.x = x;
        this.y = y;
    }

//get
    public double getX() {return x;}
    public double getY() {return y;}


//set
    public void setX(double x) {
        this.x = x;
    }

    public void setY(double y) {
        this.y = y;
    }

    public double move(double x, double y) {
        double xAntigo = this.x;
        double yAntigo = this.y;
        this.x = x;
        this.y = y;
        return Math.sqrt(Math.pow(xAntigo - x, 2) + Math.pow(yAntigo - y, 2)); // distancia
    }

@Override
//toString
    public String toString() {
        return String.format("Objeto movel nas coordenadas (%d; %d)", x, y);
    }
}